
	** Urban status
	
		use "$dir/rawdata/LSMS Tanzania/2012/HH_SEC_A.dta", clear
		
		gen w3_urban=y3_rural==0 if !missing(y3_rural)
		ta
		keep y3_hhid w3_*
		
		tempfile urban
		save `urban', replace
		
	** Roster
	
		use "$dir/rawdata/LSMS Tanzania/2012/HH_SEC_B.dta", clear
		
		gen w3_female=hh_b02==2 if !missing(hh_b02)
		gen w3_age=hh_b04
		
		gen w3_inhh=1 if hh_b09_2!="X"
		
		gen w3_married=(hh_b19==1 | hh_b19==2) if !missing(hh_b19)
		
		bys y3_hhid: egen w3_hh_size=total(w3_inhh)
		
		keep y3_hhid y2_hhid indidy3 w3_*
		
		tempfile roster
		save `roster', replace
		
	** Employment 
	
		use "$dir/rawdata/LSMS Tanzania/2012/HH_SEC_E.dta", clear
	
		** Working for a wage outside the household
			gen w3_work_outsideHH=(hh_e08b==1) if !missing(hh_e08b)
			gen w3_work_outsideHH_hrs=hh_e32
			replace w3_work_outsideHH_hrs=w3_work_outsideHH_hrs+hh_e50 if !missing(hh_e50)
			replace w3_work_outsideHH_hrs=0 if w3_work_outsideHH==0
			
		** Working in agriculture for a HH member
			gen w3_work_agHH=hh_e08e==1 if !missing(hh_e08e)
			gen w3_work_agHH_hrs=hh_e69
			
		** Working in HH business
			gen w3_work_bizHH=(hh_e08c==1 | hh_e08d==1 | hh_e63==1) if (!missing(hh_e08c) | !missing(hh_e08d) | !missing(hh_e63))
			gen w3_work_bizHH_hrs=hh_e64
			
		** Any work in last 7 days (agriculture, for non-HH member, own account/business)
			egen w3_worked_last7days=rowmax(w3_work_outsideHH w3_work_agHH w3_work_bizHH)
		
		** Hours worked in last 7 days
			egen w3_work_hrs=rowtotal(w3_work_outsideHH_hrs w3_work_agHH_hrs w3_work_bizHH_hrs)
			replace w3_work_hrs=. if missing(w3_work_outsideHH_hrs) & missing(w3_work_agHH_hrs) & missing(w3_work_bizHH_hrs)
		
		keep y3_hhid indidy3 w3_*
		
		tempfile employment
		save `employment', replace
		
	** Illness and injury
		
		*n/a
	
	** Disabilities
	
		*n/a

	
	** Merge and save
	
		use `roster', clear
		merge 1:1 y3_hhid indidy3 using `employment', gen(merge_employment)
		merge m:1 y3_hhid using `urban', gen(merge_urban)
		
		ren y3_hhid hhid_w3
		ren indidy3 indiv_w3
		ren y2_hhid hhid_w2
		
		save "$dir/data/tza_w3_individual.dta", replace
